//
//  HomePageViewController.m
//  GouWoAi
//
//  Created by 赵佟越 on 16/5/5.
//  Copyright © 2016年 zhaotongyue. All rights reserved.
//

#import "HomePageViewController.h"
#import "SMS_Scroll_ImageView.h"
#import "ShopCollectionViewCell.h"
#import "HomePageRemaiTableViewCell.h"
#import "HomePageRemai01TableViewCell.h"

@interface HomePageViewController ()<UITableViewDataSource,UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate>

@property(nonatomic, strong)UITableView *myTableView;

@property(nonatomic, strong)NSArray *ImageURLArr;

@property(nonatomic, strong)UIButton *YouhuiBtn;

@property(nonatomic, strong)UIButton *TejiaBtn;

@property(nonatomic, strong)UIButton *QianDaoBtn;

@property(nonatomic, strong)UIButton *HongBaoBtn;

@property(nonatomic, strong)UIButton *KuaiDiBtn;

@property(nonatomic, strong)UIButton *LifeBtn;

@property(nonatomic, strong)UIButton *RecoverBtn;

@property(nonatomic, strong)UIButton *ExchangeBtn;

@property(nonatomic, strong)UIButton *moreShopBtn;

@property(nonatomic, strong)UIButton *LeadBtn;

@property(nonatomic, strong)UIButton *LeadBtn1;

@property(nonatomic, strong)UIButton *LeadBtn2;

@property(nonatomic, strong)UICollectionView *myCollectionView;

@property(nonatomic, strong)UICollectionViewFlowLayout *layout;

@property(nonatomic, strong)UILabel *shopTimeLabel;
@end

@implementation HomePageViewController
{
    UILabel *_labelTitle;
    UILabel *_labelTime;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self layoutNavigationBar];
    [self makeBaseUI];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    //    字体颜色
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}

#pragma mark - Private Methods
- (void)layoutNavigationBar {
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor getColorFromRGBString:@"#F48000"];
    self.title = @"首页";
    self.view.backgroundColor = [UIColor getColorFromRGBString:@"#F2F2F2"];
    
    UIButton *rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 18, 18)];
    rightButton.titleLabel.font = [UIFont systemFontOfSize:17];
    [rightButton setImage:[UIImage imageNamed:@"sysicon_n_12@1x"] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(rightButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;
    
    UIButton *leftButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 18, 18)];
    leftButton.titleLabel.font = [UIFont systemFontOfSize:17];
    [leftButton setImage:[UIImage imageNamed:@"sysicon_n_11@1x"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(leftButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    
    self.navigationItem.titleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH - 80, 44)];
    _labelTitle = [[UILabel alloc]init];
    _labelTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    _labelTitle.textAlignment = NSTextAlignmentCenter;
    _labelTitle.text = @"青年汇便利店";
    _labelTitle.textColor = [UIColor whiteColor];
    
    [self.navigationItem.titleView addSubview:_labelTitle];
    
    [self.navigationItem.titleView addSubview:self.shopTimeLabel];
    self.shopTimeLabel.text = @"营业时间 8:00 - 23:00 ";
    
    [self.navigationItem.titleView addSubview:self.moreShopBtn];
    
    [_labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.navigationItem.titleView).offset(10);
        make.left.equalTo(self.navigationItem.titleView);
        make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH - 80, 14));
    }];
    
    [self.shopTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_labelTitle.mas_bottom).offset(5);
        make.left.equalTo(self.navigationItem.titleView);
        make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH - 80, 9));
    }];
    
    
    [self.moreShopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_labelTitle);
        // 字数一半 *14 + 30 ...
        make.centerX.equalTo(_labelTitle).offset(3 * 14 + 20);
        make.size.mas_equalTo(CGSizeMake(16, 8));
        
    }];
    
}

- (void)makeBaseUI{
    [self.view addSubview:self.myTableView];
    
    
}
#pragma mark - tableview delegate & datasource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 4) {
        return 5;
    }else{
        return 1;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 116;
    }else{
        return 8;
    }
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//    if (section == 4) {
//        UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 150)];
//        UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, ZTY_SCREEN_WIDTH, 17)];
//        myLabel.text = @"查看更多商品";
//        
//        
//    }else{
        return nil;
//    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 4) {
        return 150;
    }
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        UIView *scrBackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 116)];
        SMS_Scroll_ImageView *myView = [[SMS_Scroll_ImageView alloc]initWithSMS_ImagePath1:@"eat_" ImagePath2:@".jpg" ImageCount:3 IntervalTime:2 Frame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH , 108) PageControl:YES PageNumber:NO];
        [scrBackView addSubview:myView];
        return scrBackView;
    }else{
        return nil;
    }
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 70;
    }else if(indexPath.section == 1){
        return 122;
    }else if(indexPath.section == 2){
        return 86;
    }else if(indexPath.section == 3){
        return 205;
    }else if(indexPath.section == 4 && indexPath.row == 0){
        return 160 + 13 + 13 + 40 + 110 - (90 - 14);
    }else{
        return 160 + 13;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell0 = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell0) {
        cell0 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell0.textLabel.textAlignment = NSTextAlignmentCenter;
        cell0.textLabel.textColor = [UIColor orangeColor];
        
    }
    if (indexPath.section == 0) {
        [cell0.contentView addSubview:self.TejiaBtn];
        [cell0.contentView addSubview:self.YouhuiBtn];
        [cell0.contentView addSubview:self.QianDaoBtn];
        [cell0.contentView addSubview:self.HongBaoBtn];
        
        [self.YouhuiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0.mas_top);
            make.left.equalTo(cell0.mas_left);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 65));
        }];
        
        [self.TejiaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0.mas_top);
            make.left.equalTo(cell0.mas_left).offset(ZTY_SCREEN_WIDTH/4);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 65));
        }];
        
//        [self.TejiaBtn.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(self.TejiaBtn).offset(5);
//            make.left.equalTo(self.TejiaBtn);
//        }];
        
        [self.QianDaoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0.mas_top);
            make.left.equalTo(cell0.mas_left).offset(ZTY_SCREEN_WIDTH/4 * 2);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 65));
        }];
        
        [self.HongBaoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0.mas_top);
            make.left.equalTo(cell0.mas_left).offset(ZTY_SCREEN_WIDTH/4 * 3);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4 , 65));
        }];
    }else if(indexPath.section == 1){
        [cell0.contentView addSubview:self.LeadBtn];
        [cell0.contentView addSubview:self.LeadBtn1];
        [cell0.contentView addSubview:self.LeadBtn2];
        cell0.backgroundColor = [UIColor getColorFromRGBString:@"#F2F2F2"];
        
        [self.LeadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(cell0);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/2 - 2.5, 122));
        }];
        
        [self.LeadBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/2 + 2.5);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/2 - 2.5, 61 - 2.5));
        }];
        
        [self.LeadBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0).offset(61 + 2.5);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/2 + 2.5);
            
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/2 - 2.5, 61 - 2.5));
        }];
        
        [self.LeadBtn1.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/4 * 3 + 2.5);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4 -2.5, 61 - 2.5));
        }];
        
        [self.LeadBtn2.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0).offset(61 + 2.5);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/4 * 3 + 2.5);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4 -2.5, 61 - 2.5));
        }];
        
        
        
    }else if(indexPath.section == 2){
        [cell0.contentView addSubview:self.KuaiDiBtn];
        [cell0.contentView addSubview:self.LifeBtn];
        [cell0.contentView addSubview:self.RecoverBtn];
        [cell0.contentView addSubview:self.ExchangeBtn];
        
        [self.KuaiDiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(cell0);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 86));
        }];
        
        [self.LifeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/4);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 86));
        }];
        
        [self.RecoverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/4 * 2);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 86));
        }];
        
        [self.ExchangeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0);
            make.left.equalTo(cell0).offset(ZTY_SCREEN_WIDTH/4 * 3);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH/4, 86));
        }];
        
    }else if (indexPath.section == 3){
        cell0.selectionStyle = UITableViewCellSelectionStyleNone;
        UIImageView *myimageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sysicon_n_06"]];
        [cell0.contentView addSubview:myimageView];
        [myimageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell0).offset(15);
            make.top.equalTo(cell0).offset(7);
            make.size.mas_equalTo(CGSizeMake(15, 18));
        }];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, ZTY_SCREEN_WIDTH - 40, 28)];
        label.text = @"购我爱推荐";
        label.font = [UIFont systemFontOfSize:12];
        label.textColor = [UIColor getColorFromRGBString:@"868686"];
        [cell0.contentView addSubview:label];
        
        [cell0.contentView addSubview:self.myCollectionView];
        
        [self.myCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(cell0).offset(40);
            make.left.equalTo(cell0);
            make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH, 165));
        }];
    }else if (indexPath.section == 4 && indexPath.row == 0){
        HomePageRemaiTableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        if (!cell1) {
            cell1 = [[HomePageRemaiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
        }
        cell1.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell1;
    }else if(indexPath.section == 4 && indexPath.row > 0){
        HomePageRemai01TableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        if (!cell2) {
            cell2 = [[HomePageRemai01TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell2"];
        }
        cell2.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell2;
    }
    return cell0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - CollectionView DataSource And DeleGate



- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"section, : %lu, item:%ld",indexPath.section, indexPath.item);
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 100;
}



- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ShopCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}




#pragma mark - Button Action

- (void)rightButtonAction:(UIButton *)sender{
    // 搜索
}

- (void)leftButtonAction:(UIButton *)sender{
    [self.myTableView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(32);
        make.size.mas_equalTo(CGSizeMake(ZTY_SCREEN_WIDTH, 666));
    }];
    UIView *ViewTip = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, 32)];
    ViewTip.backgroundColor = [UIColor getColorFromRGBString:@"fff2be"];
    UILabel *labelTip = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, ZTY_SCREEN_WIDTH, 32)];
    labelTip.text = @"您已不再青年水果超市附近, 是否选择周边购我爱";
    labelTip.font = [UIFont systemFontOfSize:15];
    labelTip.textColor = [UIColor getColorFromRGBString:@"898472"];
    [ViewTip addSubview:labelTip];
    
    [self.view addSubview:ViewTip];
    
    // 扫一扫
}

- (void)TejiaBtnAction:(UIButton *)sender{
    // 特价
}

- (void)QianDaoBtnAction:(UIButton *)sender{
    // 签到
}

- (void)YouhuiBtnAction:(UIButton *)sender{
    // 摇优惠
}

- (void)HongBaoBtnAction:(UIButton *)sender{
    // 抢红包
}

- (void)ExchangeBtn:(UIButton *)sender{
    // 积分兑换
}

- (void)LifeBtn:(UIButton *)sender{
    // 生活服务
}

- (void)RecoverBtn:(UIButton *)sender{
    // 废品回收
}

- (void)KuaiDiBtn:(UIButton *)sender{
    // 快递
}

- (void)LeadBtnAction:(UIButton *)sender{
    // 拼团购优惠
}

- (void)LeadBtn1Action:(UIButton *)sender{
    // 产品预购
}

- (void)LeadBtn2Action:(UIButton *)sender{
    // 限量秒杀
}




#pragma mark - LazyLode

- (UITableView *)myTableView{
    if (_myTableView == nil) {
        _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ZTY_SCREEN_WIDTH, ZTY_SCREEN_HEIGHT) style:UITableViewStyleGrouped];
        _myTableView.dataSource = self;
        _myTableView.delegate = self;
        _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _myTableView;
}

- (UIButton *)TejiaBtn{
    if (_TejiaBtn == nil) {
        _TejiaBtn = [[UIButton alloc]init];
        [_TejiaBtn setImage:[UIImage imageNamed:@"first_icon_02"] forState:UIControlStateNormal];
        [_TejiaBtn setImageEdgeInsets:UIEdgeInsetsMake(7 , 27 * _ZTY_SCREEN_WIDTH, 65  - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) - 7 , 27 * _ZTY_SCREEN_WIDTH)];
        [_TejiaBtn setTitle:@"特价专区" forState:UIControlStateNormal];
        _TejiaBtn.backgroundColor = [UIColor whiteColor];
        _TejiaBtn.backgroundColor = [UIColor whiteColor];
        [_TejiaBtn setTitleColor:[UIColor getColorFromRGBString:@"909090"] forState:UIControlStateNormal];
        [_TejiaBtn setTitleEdgeInsets:UIEdgeInsetsMake(70 - 15 + 5, -54, 9, 9)];
        _TejiaBtn.font = [UIFont systemFontOfSize:10];
        [_TejiaBtn addTarget:self action:@selector(TejiaBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _TejiaBtn;
}

- (UIButton *)YouhuiBtn{
    if (_YouhuiBtn == nil) {
        _YouhuiBtn = [[UIButton alloc]init];
        [_YouhuiBtn setImage:[UIImage imageNamed:@"first_icon_01"] forState:UIControlStateNormal];
        [_YouhuiBtn setImageEdgeInsets:UIEdgeInsetsMake(7 , 27 * _ZTY_SCREEN_WIDTH, 65  - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) - 7 , 27 * _ZTY_SCREEN_WIDTH)];
        [_YouhuiBtn setTitle:@"摇优惠" forState:UIControlStateNormal];
        [_YouhuiBtn setTitleColor:[UIColor getColorFromRGBString:@"909090"] forState:UIControlStateNormal];
        [_YouhuiBtn setTitleEdgeInsets:UIEdgeInsetsMake((70 - 15 + 5), -54, 9 , 9 )];
        _YouhuiBtn.font = [UIFont systemFontOfSize:10];
        _YouhuiBtn.backgroundColor = [UIColor whiteColor];
        [_YouhuiBtn addTarget:self action:@selector(YouhuiBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _YouhuiBtn;
}

- (UIButton *)QianDaoBtn{
    if (_QianDaoBtn == nil) {
        _QianDaoBtn = [[UIButton alloc]init];
        [_QianDaoBtn setImage:[UIImage imageNamed:@"first_icon_03"] forState:UIControlStateNormal];
        [_QianDaoBtn setImageEdgeInsets:UIEdgeInsetsMake(7 , 27 * _ZTY_SCREEN_WIDTH, 65  - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) - 7 , 27 * _ZTY_SCREEN_WIDTH)];
        [_QianDaoBtn setTitle:@"每日签到" forState:UIControlStateNormal];
        _QianDaoBtn.backgroundColor = [UIColor whiteColor];
        [_QianDaoBtn setTitleColor:[UIColor getColorFromRGBString:@"909090"] forState:UIControlStateNormal];
        [_QianDaoBtn setTitleEdgeInsets:UIEdgeInsetsMake(70 - 15 + 5, -54, 9, 9)];
        _QianDaoBtn.font = [UIFont systemFontOfSize:10];
        [_QianDaoBtn addTarget:self action:@selector(QianDaoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _QianDaoBtn;
}

- (UIButton *)HongBaoBtn{
    if (_HongBaoBtn == nil) {
        _HongBaoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_HongBaoBtn setImage:[UIImage imageNamed:@"first_icon_04"] forState:UIControlStateNormal];
        [_HongBaoBtn setImageEdgeInsets:UIEdgeInsetsMake(7 , 27 * _ZTY_SCREEN_WIDTH, 65  - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) - 7 , 27 * _ZTY_SCREEN_WIDTH)];
        [_HongBaoBtn setTitle:@"抢红包" forState:UIControlStateNormal];
        _HongBaoBtn.backgroundColor = [UIColor whiteColor];
        [_HongBaoBtn setTitleColor:[UIColor getColorFromRGBString:@"909090"] forState:UIControlStateNormal];
        [_HongBaoBtn setTitleEdgeInsets:UIEdgeInsetsMake(70 - 15 + 5, -54, 9, 9)];
        _HongBaoBtn.font = [UIFont systemFontOfSize:10];
        [_HongBaoBtn addTarget:self action:@selector(HongBaoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _HongBaoBtn;
}

- (UIButton *)KuaiDiBtn{
    if (_KuaiDiBtn == nil) {
        _KuaiDiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_KuaiDiBtn setImage:[UIImage imageNamed:@"first_icon_05"] forState:UIControlStateNormal];
        [_KuaiDiBtn setImageEdgeInsets:UIEdgeInsetsMake(39 , 27 * _ZTY_SCREEN_WIDTH, 86 - 39  - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) , 27 * _ZTY_SCREEN_WIDTH)];
        [_KuaiDiBtn setTitle:@"快递服务" forState:UIControlStateNormal];
        _KuaiDiBtn.backgroundColor = [UIColor whiteColor];
        [_KuaiDiBtn setTitleColor:[UIColor getColorFromRGBString:@"d4af8f"] forState:UIControlStateNormal];
        [_KuaiDiBtn setTitleEdgeInsets:UIEdgeInsetsMake(12, -54, 51, 9)];
        [_KuaiDiBtn addTarget:self action:@selector(KuaiDiBtn:) forControlEvents:UIControlEventTouchUpInside];
        _KuaiDiBtn.font = [UIFont systemFontOfSize:12];
    }
    return _KuaiDiBtn;
}

- (UIButton *)LifeBtn{
    if (_LifeBtn == nil) {
        _LifeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_LifeBtn setImage:[UIImage imageNamed:@"first_icon_06"] forState:UIControlStateNormal];
        [_LifeBtn setImageEdgeInsets:UIEdgeInsetsMake(39, 27 * _ZTY_SCREEN_WIDTH, 86 - 39 - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) , 27 * _ZTY_SCREEN_WIDTH)];
        [_LifeBtn setTitle:@"生活服务" forState:UIControlStateNormal];
        _LifeBtn.backgroundColor = [UIColor whiteColor];
        [_LifeBtn setTitleColor:[UIColor getColorFromRGBString:@"d4af8f"] forState:UIControlStateNormal];
        [_LifeBtn setTitleEdgeInsets:UIEdgeInsetsMake(12, -54, 51, 9)];
        [_LifeBtn addTarget:self action:@selector(LifeBtn:) forControlEvents:UIControlEventTouchUpInside];
        _LifeBtn.font = [UIFont systemFontOfSize:12];
    }
    return _LifeBtn;
}


- (UIButton *)RecoverBtn{
    if (_RecoverBtn == nil) {
        _RecoverBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_RecoverBtn setImage:[UIImage imageNamed:@"first_icon_07"] forState:UIControlStateNormal];
        [_RecoverBtn setImageEdgeInsets:UIEdgeInsetsMake(39, 27 * _ZTY_SCREEN_WIDTH, 86 - 39 - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) , 27 * _ZTY_SCREEN_WIDTH)];
        [_RecoverBtn setTitle:@"废品回收" forState:UIControlStateNormal];
        _RecoverBtn.backgroundColor = [UIColor whiteColor];
        [_RecoverBtn setTitleColor:[UIColor getColorFromRGBString:@"d4af8f"] forState:UIControlStateNormal];
        [_RecoverBtn setTitleEdgeInsets:UIEdgeInsetsMake(12, -54, 51, 9)];
        [_RecoverBtn addTarget:self action:@selector(RecoverBtn:) forControlEvents:UIControlEventTouchUpInside];
        _RecoverBtn.font = [UIFont systemFontOfSize:12];
    }
    return _RecoverBtn;
}

- (UIButton *)ExchangeBtn{
    if (_ExchangeBtn == nil) {
        _ExchangeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_ExchangeBtn setImage:[UIImage imageNamed:@"first_icon_08"] forState:UIControlStateNormal];
        [_ExchangeBtn setImageEdgeInsets:UIEdgeInsetsMake(39, 27 * _ZTY_SCREEN_WIDTH, 86 - 39 - (ZTY_SCREEN_WIDTH/4 - 54 * _ZTY_SCREEN_WIDTH) , 27 * _ZTY_SCREEN_WIDTH)];
        [_ExchangeBtn setTitle:@"积分兑换" forState:UIControlStateNormal];
        _ExchangeBtn.backgroundColor = [UIColor whiteColor];
        [_ExchangeBtn setTitleColor:[UIColor getColorFromRGBString:@"d4af8f"] forState:UIControlStateNormal];
        [_ExchangeBtn setTitleEdgeInsets:UIEdgeInsetsMake(12, -54, 51, 9)];
        [_ExchangeBtn addTarget:self action:@selector(ExchangeBtn:) forControlEvents:UIControlEventTouchUpInside];
        
        _ExchangeBtn.font = [UIFont systemFontOfSize:12];
    }
    return _ExchangeBtn;
}

- (UIButton *)moreShopBtn{
    if (_moreShopBtn == nil) {
        _moreShopBtn = [[UIButton alloc]init];
        [_moreShopBtn setImage:[UIImage imageNamed:@"xia"] forState:UIControlStateNormal];
    }
    return _moreShopBtn;
}

- (UIButton *)LeadBtn{
    if (_LeadBtn == nil) {
        _LeadBtn = [[UIButton alloc]init];
        [_LeadBtn setImage:[UIImage imageNamed:@"user_pic_19"] forState:UIControlStateNormal];
        [_LeadBtn addTarget:self action:@selector(LeadBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _LeadBtn;
}

- (UIButton *)LeadBtn1{
    if (_LeadBtn1 == nil) {
        _LeadBtn1 = [[UIButton alloc]init];
        [_LeadBtn1 setImage:[UIImage imageNamed:@"user_pic_01"] forState:UIControlStateNormal];
        [_LeadBtn1 addTarget:self action:@selector(LeadBtn1Action:) forControlEvents:UIControlEventTouchUpInside];
        
        UILabel *labeltip = [[UILabel alloc]initWithFrame:CGRectMake(7, 10, ZTY_SCREEN_WIDTH/2 - 2.5, 12)];
        labeltip.text = @"产品预购";
        labeltip.textColor = [UIColor getColorFromRGBString:@"545353"];
        labeltip.font = [UIFont systemFontOfSize:12];
        
        UILabel *labeldetail = [[UILabel alloc]initWithFrame:CGRectMake(7, 32, ZTY_SCREEN_WIDTH/2 - 2.5, 12)];
        labeldetail.text = @"一起囤好货";
        labeldetail.textColor = [UIColor getColorFromRGBString:@"bebebe"];
        labeldetail.font = [UIFont systemFontOfSize:11];
        [_LeadBtn1 addSubview:labeldetail];
        [_LeadBtn1 addSubview:labeltip];
        _LeadBtn1.backgroundColor = [UIColor whiteColor];
        
    }
    return _LeadBtn1;
}

- (UIButton *)LeadBtn2{
    if (_LeadBtn2 == nil) {
        _LeadBtn2 = [[UIButton alloc]init];
        [_LeadBtn2 setImage:[UIImage imageNamed:@"user_pic_02"] forState:UIControlStateNormal];
        _LeadBtn2.backgroundColor = [UIColor whiteColor];
        _labelTime = [[UILabel alloc]initWithFrame:CGRectMake(7, 5, ZTY_SCREEN_WIDTH/2 - 2.5, 12)];
        _labelTime.text = @"20 : 10 : 18.0";
        _labelTime.font = [UIFont systemFontOfSize:12];
        [_LeadBtn2 addTarget:self action:@selector(LeadBtn2Action:) forControlEvents:UIControlEventTouchUpInside];
        
        [_LeadBtn2 addSubview:_labelTime];
        
        UILabel *labelTip = [[UILabel alloc]initWithFrame:CGRectMake(7, 23, ZTY_SCREEN_WIDTH/2 - 2.5, 12)];
        labelTip.text =@"限量⚡️秒杀";
        labelTip.font = [UIFont systemFontOfSize:12];
        [_LeadBtn2 addSubview:labelTip];
        
        
        UILabel *labelDetail = [[UILabel alloc]initWithFrame:CGRectMake(7, 40, ZTY_SCREEN_WIDTH/2 - 2.5, 12)];
        labelDetail.text = @"好货秒杀不停";
        labelDetail.font = [UIFont systemFontOfSize:11];
        labelDetail.textColor = [UIColor getColorFromRGBString:@"bebebe"];
        [_LeadBtn2 addSubview:labelDetail];
        
        
        
    }
    return _LeadBtn2;
}

- (UICollectionViewFlowLayout *)layout{
    if (_layout == nil) {
        _layout = [[UICollectionViewFlowLayout alloc]init];
        _layout.itemSize =CGSizeMake((ZTY_SCREEN_WIDTH - 12) /3, 160);
        // 滚动方向
        _layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        //  section边距
        _layout.sectionInset = UIEdgeInsetsMake(8, 0, 10, 0);
        // item 边距
        
        // 列间距
        _layout.minimumInteritemSpacing = 1;
        // 行间距
        _layout.minimumLineSpacing = 1;
        //
        _layout.headerReferenceSize = CGSizeMake(0, 10);
        
        
        
    }
    return _layout;
}


- (UICollectionView *)myCollectionView{
    if (_myCollectionView == nil) {
        _myCollectionView = [[UICollectionView alloc]initWithFrame:self.view.frame collectionViewLayout:self.layout];
        _myCollectionView.delegate = self;
        _myCollectionView.dataSource = self;
        //        _myCollectionView.contentInset = UIEdgeInsetsMake(2, 0, 2, 0);
        [_myCollectionView registerClass:[ShopCollectionViewCell class] forCellWithReuseIdentifier:@"item"];
        
        _myCollectionView.backgroundColor = [UIColor getColorFromRGBString:@"F2F2F2"];
        
    }
    return _myCollectionView;
}

- (UILabel *)shopTimeLabel{
    if (_shopTimeLabel == nil) {
        _shopTimeLabel = [[UILabel alloc]init];
        _shopTimeLabel.font = [UIFont systemFontOfSize:10];
        _shopTimeLabel.textAlignment = NSTextAlignmentCenter;
        _shopTimeLabel.textColor = [UIColor whiteColor];
    }
    return _shopTimeLabel;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
